package top.txl.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import top.txl.entity.Category;
import top.txl.entity.Flavors;

import java.util.List;

@Mapper
public interface CategoryMapper extends BaseMapper<Category> {
    @Select("insert into category(type, name, create_time, update_time, create_user, update_user) values(#{type},#{name},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void add(Category category);

    @Select("update category set name =#{name},type=#{type},update_user=#{updateUser},update_time=#{updateTime}  where id=#{id}")
    void edit(Category category);

    @Select("delete from category where id = #{id}")
    void delete(Integer id);

//    @Select("select id, type, name, sort, update_time updateTime from category")
    List<Category> lists(Integer type);

    @Select("select id, type, name, sort, update_time updateTime from category where id=#{id}")
    Category detail(Integer id);

    @Select("select count(*) from dish where category_id = #{id}")
    Integer countD(Integer id);

    @Select("select count(*) from setmeal where category_id = #{id}")
    Integer countM(Integer id);

    /**
     * 口味
     * @return
     */
    @Select("select * from flavors")
    List<Flavors> flavors();
}
